//
//  ImportantIndurstrySearchViewController.m
//  Utils
//
//  Created by enghou on 2018/6/19.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "ImportantIndurstrySearchViewController.h"
#import "LocalPersistent.h"
#import "PropertyDictItemModel.h"
@interface ImportantIndurstrySearchViewController ()


@property (weak, nonatomic) IBOutlet UITextField *nameField;

@property (weak, nonatomic) IBOutlet UITextField *addressField;

@property (weak, nonatomic) IBOutlet UITextField *typeField;

@property (weak, nonatomic) IBOutlet UITextField *xingzhiField;

@property (weak, nonatomic) IBOutlet UITextField *cardNumField;

@property (weak, nonatomic) IBOutlet UITextField *politicField;

@property (weak, nonatomic) IBOutlet UITextField *manipulatorField;

@property (weak, nonatomic) IBOutlet UITextField *manipulatorTelField;

@property (weak, nonatomic) IBOutlet UITextField *manipulatorMobileField;

@property (weak, nonatomic) IBOutlet UITextField *enterpriseTelField;

@property (weak, nonatomic) IBOutlet UITextField *enterpriseFaxField;

@property (weak, nonatomic) IBOutlet UITextField *peoplesMinField;

@property (weak, nonatomic) IBOutlet UITextField *peoplesMaxField;

@property (weak, nonatomic) IBOutlet UITextField *chipMinField;

@property (weak, nonatomic) IBOutlet UITextField *chipMaxField;

@property(nonatomic,copy)PropertyDictItemModel *industryType;
@property(nonatomic,strong)NSArray *industryTypes;

@property(nonatomic,copy)PropertyDictItemModel *quality;
@property(nonatomic,strong)NSArray *qualitys;



@end

@implementation ImportantIndurstrySearchViewController

-(instancetype)init{
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"ImportantIndurstry" bundle:[NSBundle mainBundle]];
    return [story instantiateViewControllerWithIdentifier:@"ImportantIndurstrySearchViewController"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *searchButton = [[UIBarButtonItem alloc]initWithTitle:@"查询" style:UIBarButtonItemStylePlain target:self action:@selector(search)];
    self.navigationItem.rightBarButtonItem = searchButton;
}

-(void)search{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    NSString *orgId = [[LocalPersistent sharedInstance]contentForKey:@"orgId"];
    if (orgId) {
        [param setObject:orgId
                  forKey:@"orgId"];
    }
    [param setObject:self.nameField.text forKey:@"keyIndustry.name"];
    [param setObject:self.addressField.text forKey:@"keyIndustry.address"];
    if (self.industryType.ids) {
        [param setObject:self.industryType.ids forKey:@"keyIndustry.industryType.id"];
    }
    if (self.quality.ids) {
        [param setObject:self.quality.ids forKey:@"keyIndustry.quality.id"];
    }
    [param setObject:self.cardNumField.text forKey:@"keyIndustry.licenseNumber"];
    [param setObject:self.politicField.text forKey:@"keyIndustry.nativePoliceStation"];
    [param setObject:self.manipulatorField.text forKey:@"keyIndustry.legalRepresentative"];
    [param setObject:self.manipulatorTelField.text forKey:@"keyIndustry.legalPersonPhone"];
    [param setObject:self.manipulatorMobileField.text forKey:@"keyIndustry.mobileNumber"];
    [param setObject:self.enterpriseTelField.text forKey:@"keyIndustry.telephone"];
    [param setObject:self.enterpriseFaxField.text forKey:@"keyIndustry.faxTelephone"];
    [param setObject:self.peoplesMinField.text forKey:@"keyIndustry.minEmployeesNumber"];
    [param setObject:self.peoplesMaxField.text forKey:@"keyIndustry.maxEmployeesNumber"];
    [param setObject:self.chipMinField.text forKey:@"keyIndustry.minRegisteredCapital"];
    [param setObject:self.chipMaxField.text forKey:@"keyIndustry.maxRegisteredCapital"];
    if ([self.theDelete respondsToSelector:@selector(fetchModel:)]) {
        [self.theDelete fetchModel:param];
    }
    [self pop];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)chooseType{
    [self commonAlertWithContent:@"行业类型" choosenBlock:^(PropertyDictItemModel *model) {
        self.industryType = model;
        self.typeField.text = model.displayName;
    } getList:^(NSArray *list) {
        self.industryTypes = list;
    }];
}

-(void)chooseQuality{
    [self commonAlertWithContent:@"行业性质" choosenBlock:^(PropertyDictItemModel *model) {
        self.quality = model;
        self.xingzhiField.text = model.displayName;
    } getList:^(NSArray *list) {
        self.qualitys = list;
    }];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 2) {
        [self chooseType];
    }else if (indexPath.row == 3){
        [self chooseQuality];
    }
}

@end
